package com.example.game.console.controller;

import com.example.game.module.dto.LoginDTO;
import com.example.game.module.entity.User;
import com.example.game.module.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/console")
public class ConsoleLoginController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public ResponseEntity<String> login(@RequestParam String phone,
                                     @RequestParam String password,
                                     HttpSession session) {
        User user = userService.login(phone, password);
        session.setAttribute("user", user);
        return ResponseEntity.ok("登录成功");
    }
}
